<template>
    <view v-if="isVisible">
        <view class="assistant-button">
            <text class="assistant-text" @tap="handleAssistantClick">客服助手</text>
            <view class="mini-close-button" @tap="isVisible = false">
                <u-icon name="close" color="#FFF" size="12"></u-icon>
            </view>
        </view>

        <view class="full-image-modal" v-if="isFullImageVisible" @tap="isFullImageVisible = false">
            <view class="modal-content" @tap.stop>
                <image :src="imageUrl" mode="widthFix" class="full-image" />
                <view class="modal-close-button" @tap="isFullImageVisible = false">
                    <u-icon name="close" color="#FFF" size="20"></u-icon>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
import { trackButton } from '@/utils/track';

export default {
    name: 'FloatingImage',
    data() {
        return {
            isVisible: true,
            isFullImageVisible: false,
            imageUrl: '/static/images/qrcode.png'
        }
    },
    methods: {
        show() {
            this.isVisible = true
        },
        handleAssistantClick() {
            this.isFullImageVisible = true;
        }
    }
}
</script>

<style lang="scss" scoped>
.assistant-button {
    position: fixed;
    width: 45px;
    right: 5px;
    bottom: 10%;
    z-index: 999;
    background: #ec6953;
    padding: 4px 6px;
    border-radius: 15px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;

    &:active {
        opacity: 0.9;
    }
}

.assistant-text {
    color: #fff;
    font-size: 28rpx;
    font-weight: 500;
}

.mini-close-button {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    &:active {
        opacity: 0.8;
    }
}

.full-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    position: relative;
    width: 80%;
    max-width: 600rpx;
    background: #fff;
    border-radius: 12rpx;
    padding: 20rpx;
}

.full-image {
    width: 100%;
    border-radius: 8rpx;
}

.modal-close-button {
    position: absolute;
    top: -20rpx;
    right: -20rpx;
    width: 40rpx;
    height: 40rpx;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    &:active {
        opacity: 0.8;
    }
}
</style>